package com.git_taoxian.test3;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Test {
    public static void main(String[] args) {
        String[] str = {"刘备字玄德", "诸葛亮字孔明", "曹操字孟德", "孙权字仲谋", "关羽字云长", "张飞字翼德", "赵云字子龙", "乐进字文谦", "李典字曼成", "曹仁字子孝", "曹洪字子廉"};
//        定义一个HashMap集合
        Map<String,String> hashMap = new HashMap<>();
        Stream<String> stream = Arrays.stream(str);
        Map<String, String> map = stream.collect(Collectors.toMap(s -> s.split("字")[0], s -> s.split("字")[1]));
        map.forEach((s, s2) -> System.out.println(s+"="+s2));
    }
}
